﻿
@{
    ViewBag.Title = "网上售票登录界面";
    Layout = "~/Views/Shared/CinemaLayoutPage.cshtml";
}
@section styles{
    <link href="~/Content/UserLigon.css" rel="stylesheet" />
}
<div class="container" id="login">
    <form method="post" class="form-horizontal" ">
        <div class="form-group">
            <label for="id" class="glyphicon glyphicon-user">账号</label>
            <input type="text" class="form-control" id="id" placeholder="账号" name="id">
        </div>
        <div class="form-group">
            <label for="pwd" class="glyphicon glyphicon-lock">密码</label>
            <input type="password" class="form-control" id="pwd" placeholder="Password" name="pwd">
        </div>
        <button type="button" class="btn btn-default " id="btnlogin">登录</button> <a href="/User/Enroll" class="btn btn-primary" >注册</a>
    </form>
</div>
@section scripts{
    <script>
        $(function () {
            $("#btnlogin").click(function () {
                //利用AJAX实现提示用户是否登录成功
                $.ajax({
                    url: "/User/Login",
                    type: "Post",
                    data: { id: $("#id").val(), pwd: $("#pwd").val() },
                    success: function (data, textStatus, jqXHR) {
                        alert(data);
                        if (data == "登录成功") {
                            window.location.href = "/HomePage/HomePage";
                        }
                    },
                    error: function (data) {
                        alert(data);
                    },
                    dataType:"text",
                })
            })
        })
    </script>

}
